﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using fanfu.Business;
using System.Data;

public partial class UserControls_Header : System.Web.UI.UserControl
{   
    public StringBuilder strNav = new StringBuilder(); //导航链接

    /// <summary>
    /// 页面加载
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        int currentChannel = 0;
        try
        {
            currentChannel = Convert.ToInt32(Request["current"].ToString());
        }
        catch (Exception ex){}

        DataTable dtNav = new ChannelRule().GetTopChannel();
        for (int i = 0; i < dtNav.Rows.Count; i++)
        {
            if (i == currentChannel)
                strNav.AppendFormat("<li><a class=\"current\" href=\"{0}\">{1}</a></li>", dtNav.Rows[i]["ChannelUrl"].ToString(), dtNav.Rows[i]["ChannelName"].ToString());
            else
                strNav.AppendFormat("<li><a href=\"{0}\">{1}</a></li>", dtNav.Rows[i]["ChannelUrl"].ToString(), dtNav.Rows[i]["ChannelName"].ToString());
        }
    }

    /// <summary>
    /// 查询按钮
    /// </summary>
    protected void lbtnSearch_Click(object sender, EventArgs e)
    {
        string searchText = "Index.aspx?current=0&type=search&keyword=" + this.txtSearch.Value.Trim().ToString() + "&page=1";
        Response.Redirect(searchText);
    }
}